<?php defined('InShopNC') or exit('Access Invalid!'); ?>
<link href="<?php echo SHOP_TEMPLATES_URL; ?>/css/member.css" rel="stylesheet" type="text/css">
<style type="text/css">
    .public-top-layout, .head-search-bar, .head-user-menu, .public-nav-layout, .nch-breadcrumb-layout, #faq {
        display: none !important;
    }

    .public-head-layout {
        margin: 10px auto -10px auto;
    }

    .wrapper {
        width: 1000px;
    }

    #footer {
        border-top: none !important;
        padding-top: 30px;
    }

    #bottomAdv {
        display: none;
    }
    .nc-login-content{
        background-color: white;
        padding: 20px;
    }
    .tabmenu .tab{
        /*border-bottom: solid 1px #D8D8D8;*/

    }
    .tabmenu .tab li{
        border: 0 #D8D8D8 solid;
        width: 50%;
    }
    .tabmenu .tab .active{
        border: none;
    }
</style>
<div class="nc-login-layout">
    <div class="left-pic">
        <script type="text/javascript" src="<?php echo urlShop('adv','advshow',array('ap_id'=>377))?>"></script>
    </div>
    <div class="right-layout" style="width: 400px;float: right">
        <div class="wrap">
            <div class="tabmenu">
                <ul class="tab pngFix">
                    <li class="<?php if($output['route_op']=='index'){?>active<?php }else{?>normal <?php }?>">
                        <a href="#login-layout"><?php echo $lang['login_index_user_login']; ?></a>
                    </li>
                    <li class="<?php if($output['route_op']=='register'){?>active<?php }else{?>normal <?php }?>">
                        <a href="#login-register"><?php echo $lang['login_register_join_us']; ?></a>
                    </li>
                </ul>
            </div>
            <div class="layout-tab">
                <div class="nc-login-content"<?php if($output['route_op']=='register'){?> style="display: none;" <?php }?> id="login-layout">
                    <form id="login_form" method="post" class="bg" action="<?php echo urlShop('login','index');?>">
                        <?php Security::getToken();?>
                        <input type="hidden" name="form_submit" value="ok" />
                        <input name="nchash" type="hidden" value="<?php echo getNchash('index');?>" />
                        <dl>
                            <dt><?php echo $lang['login_index_username'];?></dt>
                            <dd style="min-height:54px;">
                                <input type="text" class="text" autocomplete="off"  name="user_name" id="user_name">
                                <label></label>
                            </dd>
                        </dl>
                        <dl>
                            <dt><?php echo $lang['login_index_password'];?> </dt>
                            <dd style="min-height:54px;">
                                <input type="password" class="text" name="password" autocomplete="off"  id="password">
                                <label></label>
                            </dd>
                        </dl>
                        <?php if(C('captcha_status_login') == '1') { ?>
                            <dl>
                                <dt><?php echo $lang['login_index_checkcode'];?></dt>
                                <dd style="min-height:54px;">
                                    <input type="text" name="captcha" class="text w50 fl" id="login_captcha" maxlength="4" size="10" />
                                    <img src="<?php echo SHOP_SITE_URL?>/index.php?act=seccode&op=makecode&nchash=<?php echo getNchash('index');?>" name="codeimage" border="0" id="login_codeimage" class="fl ml5"> <a href="javascript:void(0)" class="ml5" onclick="javascript:document.getElementById('login_codeimage').src='<?php echo SHOP_SITE_URL?>/index.php?act=seccode&op=makecode&nchash=<?php echo getNchash('index');?>&t=' + Math.random();"><?php echo $lang['login_index_change_checkcode'];?></a>
                                    <label></label>
                                </dd>
                            </dl>
                        <?php } ?>
                        <dl>
                            <dt>&nbsp;</dt>
                            <dd>
                                <input type="button" class="submit" value="<?php echo $lang['login_index_login'];?>" name="Submit">
                                <a class="forget" href="index.php?act=login&op=forget_password"><?php echo $lang['login_index_forget_password'];?></a>
                                <input type="hidden" value="<?php echo $_GET['ref_url']?>" name="ref_url">
                            </dd>
                        </dl>
                    </form>
                    <dl class="mt10 mb10">
                        <dt>&nbsp;</dt>
                        <dd><?php echo $lang['login_index_regist_now_1'];?><a title="" href="index.php?act=login&op=register&ref_url=<?php echo urlencode($output['ref_url']);?>" class="register"><?php echo $lang['login_index_regist_now_2'];?></a></dd>
                    </dl>
                    <?php if ($GLOBALS['setting_config']['qq_isuse'] == 1 || $GLOBALS['setting_config']['sina_isuse'] == 1){?>
                        <dl>
                            <dd class="nc-login-other" style="width: 100%;text-align: center;">
                                <p><?php echo $lang['nc_otherlogintip'];?></p>
                                <?php
                                $oauth_login=c('oauth_login');
                                foreach($oauth_login as $open_name=>$open_item){?>
                                <?php if ($open_item['use'] == 1){?>
                                    <a href="<?php if($open_name=='weixin'){?>javascript:weixin_login();<?php }else{?><?php echo SHOP_SITE_URL;?>/api.php?act=to<?php echo $open_name;?><?php }?>" title="<?php echo $open_item['name'];?>" class="<?php echo $open_name;?>">&nbsp;</a>
                                <?php } ?>
                                <?php }?>
                            </dd>
                        </dl>
                    <?php } ?>
                </div>
                <div class="nc-login-content"<?php if($output['route_op']=='index'){?> style="display: none;" <?php }?> id="login-register">
                    <form id="register_form" method="post" action="<?php echo urlShop('login','usersave');?>">
                        <?php Security::getToken();?>
                        <dl>
                            <dt><?php echo $lang['login_register_username'];?></dt>
                            <dd style="min-height:54px;">
                                <input type="text" id="register_user_name" name="user_name" class="text tip" title="<?php echo $lang['login_register_username_to_login'];?>"/>
                                <label></label>
                            </dd>
                        </dl>
                        <dl>
                            <dt><?php echo $lang['login_register_pwd'];?></dt>
                            <dd style="min-height:54px;">
                                <input type="password" id="register_password" name="password" class="text tip" title="<?php echo $lang['login_register_password_to_login'];?>" />
                                <label></label>
                            </dd>
                        </dl>
                        <dl>
                            <dt><?php echo $lang['login_register_ensure_password'];?></dt>
                            <dd style="min-height:54px;">
                                <input type="password" id="password_confirm" name="password_confirm" class="text tip" title="<?php echo $lang['login_register_input_password_again'];?>"/>
                                <label></label>
                            </dd>
                        </dl>
                        <dl>
                            <dt><?php echo $lang['login_register_email'];?></dt>
                            <dd style="min-height:54px;">
                                <input type="text" id="email" name="email" class="text tip" title="<?php echo $lang['login_register_input_valid_email'];?>" />
                                <label></label>
                            </dd>
                        </dl>
                        <dl>
                            <dt><?php echo $lang['login_register_member_tel'];?></dt>
                            <dd style="min-height:54px;">
                                <input type="text" id="member_tel" name="member_tel" class="text tip" title="<?php echo $lang['login_register_input_valid_member_tel'];?>" />
                                <label></label>
                            </dd>
                        </dl>
                        <?php if(C('captcha_status_register') == '1') { ?>
                            <dl>
                                <dt><?php echo $lang['login_register_code'];?></dt>
                                <dd style="min-height:54px;">
                                    <input type="text" id="register_captcha" name="captcha" class="text w50 fl tip" maxlength="4" size="10" title="<?php echo $lang['login_register_input_code'];?>" />
                                    <img src="index.php?act=seccode&op=makecode&nchash=<?php echo getNchash('register');?>" title="" name="codeimage" border="0" id="register_codeimage" class="fl ml5"/> <a href="javascript:void(0)" class="ml5" onclick="javascript:document.getElementById('register_codeimage').src='index.php?act=seccode&op=makecode&nchash=<?php echo getNchash('register');?>&t=' + Math.random();"><?php echo $lang['login_register_click_to_change_code'];?></a>
                                    <label></label>
                                </dd>
                            </dl>
                        <?php } ?>
                        <dl>
                            <dt>&nbsp;</dt>
                            <dd>
                                <input type="button" id="register_Submit" value="<?php echo $lang['login_register_regist_now'];?>" class="submit" title="<?php echo $lang['login_register_regist_now'];?>" />
                                <input name="agree" type="checkbox" class="vm ml10" id="clause" value="1" checked="checked" />
                                <span for="clause" class="ml5"><?php echo $lang['login_register_agreed'];?><a href="<?php echo urlShop('document', 'index',array('code'=>'agreement'));?>" target="_blank" class="agreement" title="<?php echo $lang['login_register_agreed'];?>"><?php echo $lang['login_register_agreement'];?></a></span>
                                <label></label>
                            </dd>
                        </dl>
                        <input type="hidden" value="<?php echo $_GET['ref_url']?>" name="ref_url">
                        <input name="nchash" type="hidden" value="<?php echo getNchash();?>" />
                    </form>
                    <div class="clear"></div>
                </div>
            </div>
            <div class="nc-login-bottom"></div>
        </div>
    </div>
</div>
<script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery.poshytip.min.js" charset="utf-8"></script>
<script>
    //注册表单提示
    $('.tip').poshytip({
        className: 'tip-yellowsimple',
        showOn: 'focus',
        alignTo: 'target',
        alignX: 'center',
        alignY: 'top',
        offsetX: 0,
        offsetY: 5,
        allowTipHover: false
    });
    //登录表单验证
    $(document).ready(function () {
        var loginMenu=$('.tabmenu li');
        loginMenu.bind('click',function(){
            loginMenu.toggleClass('active');
            $('.nc-login-content').hide();
            $(this.getElementsByTagName('a')[0].getAttribute('href')).show();
            return false;
        });
        $('input[name="Submit"]').click(function(){
            if($("#login_form").valid()){
                $("#login_form").submit();
            } else{
                document.getElementById('codeimage').src='<?php echo SHOP_SITE_URL?>/index.php?act=seccode&op=makecode&nchash=<?php echo getNchash('index');?>&t=' + Math.random();
            }
        });
        $("#login_form").validate({
            errorPlacement: function(error, element){
                var error_td = element.parent('dd');
                error_td.find('label').hide();
                error_td.append(error);
            },
            rules: {
                user_name: "required",
                password: "required"
                <?php if(C('captcha_status_login') == '1') { ?>
                ,captcha : {
                    required : true,
                    minlength: 4,
                    remote   : {
                        url : '<?php echo SHOP_SITE_URL?>/index.php?act=seccode&op=check&nchash=<?php echo getNchash('index');?>',
                        type: 'get',
                        data:{
                            captcha : function(){
                                return $('#login_captcha').val();
                            }
                        }
                    }
                }
                <?php } ?>
            },
            messages: {
                user_name: "<?php echo $lang['login_index_input_username'];?>",
                password: "<?php echo $lang['login_index_input_password'];?>"
                <?php if(C('captcha_status_login') == '1') { ?>
                ,captcha : {
                    required : '<?php echo $lang['login_index_input_checkcode'];?>',
                    minlength: '<?php echo $lang['login_index_input_checkcode'];?>',
                    remote	 : '<?php echo $lang['login_index_wrong_checkcode'];?>'
                }
                <?php } ?>
            }
        });
    });
    //注册表单验证
    $(function(){
        var registerForm=$("#register_form");
        registerForm.find('#register_Submit').click(function(){
            if(registerForm.valid()){
                ajaxpost('register_form', '', '', 'onerror');
            } else{
                document.getElementById('register_codeimage').src='<?php echo SHOP_SITE_URL?>/index.php?act=seccode&op=makecode&nchash=<?php echo getNchash('register');?>&t=' + Math.random();
            }
        });
        jQuery.validator.addMethod("lettersonly", function(value, element) {
            return this.optional(element) || /^[^:%,'\*\"\s\<\>\&]+$/i.test(value);
        }, "Letters only please");
        jQuery.validator.addMethod("lettersmin", function(value, element) {
            return this.optional(element) || ($.trim(value.replace(/[^\u0000-\u00ff]/g,"aa")).length>=3);
        }, "Letters min please");
        jQuery.validator.addMethod("lettersmax", function(value, element) {
            return this.optional(element) || ($.trim(value.replace(/[^\u0000-\u00ff]/g,"aa")).length<=45);
        }, "Letters max please");
        registerForm.validate({
            errorPlacement: function(error, element){
                var error_td = element.parent('dd');
                error_td.find('label').hide();
                error_td.append(error);
            },
            submitHandler:function(form){
                ajaxpost('register_form', '', '', 'onerror')
            },
            rules : {
                user_name : {
                    required : true,
                    lettersmin : true,
                    lettersmax : true,
                    lettersonly : true,
                    remote   : {
                        url :'index.php?act=login&op=check_member&column=ok',
                        type:'get',
                        data:{
                            user_name : function(){
                                return $('#register_user_name').val();
                            }
                        }
                    }
                },
                password : {
                    required : true,
                    minlength: 6,
                    maxlength: 20
                },
                member_tel : {
                    required : true,
                    minlength: 6,
                    maxlength: 20
                },
                password_confirm : {
                    required : true,
                    equalTo  : '#register_password'
                },
                email : {
                    required : true,
                    email    : true,
                    remote   : {
                        url : 'index.php?act=login&op=check_email',
                        type: 'get',
                        data:{
                            email : function(){
                                return $('#email').val();
                            }
                        }
                    }
                },
                <?php if(C('captcha_status_register') == '1') { ?>
                captcha : {
                    required : true,
                    minlength: 4,
                    remote   : {
                        url : 'index.php?act=seccode&op=check&nchash=<?php echo getNchash('register');?>',
                        type: 'get',
                        data:{
                            captcha : function(){
                                return $('#register_captcha').val();
                            }
                        }
                    }
                },
                <?php } ?>
                agree : {
                    required : true
                }
            },
            messages : {
                user_name : {
                    required : '<?php echo $lang['login_register_input_username'];?>',
                    lettersmin : '<?php echo $lang['login_register_username_range'];?>',
                    lettersmax : '<?php echo $lang['login_register_username_range'];?>',
                    lettersonly: '<?php echo $lang['login_register_username_lettersonly'];?>',
                    remote	 : '<?php echo $lang['login_register_username_exists'];?>'
                },
                password  : {
                    required : '<?php echo $lang['login_register_input_password'];?>',
                    minlength: '<?php echo $lang['login_register_password_range'];?>',
                    maxlength: '<?php echo $lang['login_register_password_range'];?>'
                },
                password_confirm : {
                    required : '<?php echo $lang['login_register_input_password_again'];?>',
                    equalTo  : '<?php echo $lang['login_register_password_not_same'];?>'
                },
                email : {
                    required : '<?php echo $lang['login_register_input_email'];?>',
                    email    : '<?php echo $lang['login_register_invalid_email'];?>',
                    remote	 : '<?php echo $lang['login_register_email_exists'];?>'
                },
                <?php if(C('captcha_status_register') == '1') { ?>
                captcha : {
                    required : '<?php echo $lang['login_register_input_text_in_image'];?>',
                    minlength: '<?php echo $lang['login_register_code_wrong'];?>',
                    remote	 : '<?php echo $lang['login_register_code_wrong'];?>'
                },
                <?php } ?>
                agree : {
                    required : '<?php echo $lang['login_register_must_agree'];?>'
                }
            }
        });
    });
</script>